﻿/*----------------------------------------------------------------
  //Copyright (C) 2012 赵国伟
  //文件功能描述：会用管理Ajax请求服务端处理程序。
  //创建人：赵国伟
  //生成时间：2012/04/21 16:15:00
//----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Shopping.Common;
using Shopping.Model;
using Shopping.BLL;

public partial class Manage_AS_UsersCommon : BaseManagePage
{
    private readonly UsersManage bllUser = new UsersManage();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string action = Request.QueryString["Action"] as string;
            switch (action)
            {
                case "QueryUsersAsPage":  //查询会员信息； by 赵国伟 2012-04-21
                    QueryUsersAsPage();
                    break;
            }
        }
        Response.End();
    }

    #region "分页查询所有会员信息； by 赵国伟 2012-04-21"
    /// <summary>
    /// 分页查询所有会员信息；
    /// </summary>
    private void QueryUsersAsPage()
    {
        QueryUsersAsPage q = new QueryUsersAsPage();
        q.KeyWords = Utility.G("KeyWords");
        q.CurPage = Utility.G<int>("CurPage");
        if (q.CurPage <= 0) q.CurPage = 1;

        List<Users> listOfSource = bllUser.QueryListAsPage(q);
        List<IDNameObj> listOfTarget = null;
        if (listOfSource != null)
        {
            listOfTarget = new List<IDNameObj>();
            for (int i = 0; i < listOfSource.Count; ++i)
            {
                IDNameObj d = new IDNameObj();
                d.ID = listOfSource[i].UserID;
                d.Name = listOfSource[i].UserName;
                listOfTarget.Add(d);
            }
        }
        if (listOfTarget != null)
        {
            string result = "{\"TotalCount\":" + q.TotalCount + ",\"Data\":" + JSONHelper.ObjectToJson<List<IDNameObj>>(listOfTarget) + "}";
            Response.Write(result);
        }
    }
    #endregion

}